<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏后台管理</title>
    <script src="__JS__/jquery.js"></script>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        th{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
{include file="base/header" /}
<br/>
<table class="table table-bordered">
    <tr>
        <th>编号</th>
        <th>商品名称</th>
        <th>购买数量</th>
        <th>进价</th>
        <th>售价</th>
        <th>总价</th>
        <th>实际总价</th>
        <th>订单号</th>
        <th>下单时间</th>
        <th>操作</th>
    </tr>
    {foreach $result as $val}
    <tr id="del{$val.id}" style="text-align: center">
        <td>{$val.id}</td>
        <td>{$val.pname}</td>
        <td>{$val.number}</td>
        <td>{$val.purchaseprice}</td>
        <td>{$val.retailprice}</td>
        <td>{$val.total}</td>
        <td>{$val.actualtotal}</td>
        <td>{$val.ordernumber}</td>
        <td>{$val.date}</td>
        <td>
            <button onclick="del({$val.id})" type="button" class="btn btn-danger btn-xs">删除</button>
            <button onclick="detail({$val.id})" type="button" class="btn btn-info btn-xs">详情</button>
        </td>
    </tr>
    {/foreach}
</table>
<div style="margin-left: 30px">{$result->render()}</div>
</body>
<script>
    //删除订单
    function del(id) {
        layer.confirm('你确定要删除吗?',{bnt:['确定','取消']},
            function () {
                $.ajax({
                    url:"{:url('index/order/orderDel')}",
                    type:"post",
                    data:"id="+id,
                    dataType:"json",
                    success:function (data) {
                        if(data.success){
                            layer.alert('删除成功',{bnt:['确定','取消']},
                                function () {
                                    window.location.reload();
                                },function () {
                                    window.location.reload();
                                }
                            );
                        }
                        if(data.error){
                            layer.alert('删除失败');
                        }
                    }
                });
            }
        );
    }
    //订单详情
    function detail(id) {
        window.location.href = "{:url('index/order/orderDetail')}?id="+id
    }
</script>
</html>